<template>
  <a-card :bordered="false" class="card-area">
    <!-- 查询区域 11111-->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" :label-col="labelCol" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="员工姓名">
              <a-input placeholder="请输入门店名称" v-model="queryParam.realName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="状态">
              <j-dict-select-tag placeholder="请选择状态" v-model="queryParam.status" dictCode="valid_status" />
            </a-form-item>
          </a-col>
          <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
           <a-col :md="6" :sm="24">
               <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
               <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
           </a-col>
        </span>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">添加员工</a-button>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i>
        <span>已选择</span>
        <a style="font-weight: 600">
          {{ selectedRowKeys.length }}
        </a>
        <span>项</span>
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">


        <template slot="avatarslot" slot-scope="text, record, index">
          <div class="anty-img-wrap">
            <a-avatar shape="square" :src="getAvatarView(record.avatar)" icon="user" />
          </div>
        </template>
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
                <a-menu slot="overlay">
                   <a-menu-item>
                     <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)" v-if="'0'==record.status">
                       <a>删除</a>
                     </a-popconfirm>
                   </a-menu-item>
                   <a-menu-item>
                      <a @click="handleModifyPwd(record)">重置密码</a>
                    </a-menu-item>
                   <a-menu-item v-if="'1'==record.status">
                      <a @click="handlePost({id:record.id},'/store/info/user/changeStatus','是否设为无效状态')">设为无效</a>
                   </a-menu-item>
                   <a-menu-item v-if="'0'==record.status">
                      <a @click="handlePost({id:record.id},'/store/info/user/changeStatus','是否设为有效状态')">设为有效</a>
                    </a-menu-item>
                </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->
    <!-- 表单区域 -->
    <ord-store-user-modal ref="modalForm" @ok="modalFormOk"></ord-store-user-modal>
    <ordStoreSettingPwd-modal ref="modalModifyPwdForm" @ok="modalFormOk"></ordStoreSettingPwd-modal>
  </a-card>
</template>
<script>
import '@/assets/less/TableExpand.less'
import OrdStoreUserModal from './modules/OrdStoreUserModal'
import ordStoreSettingPwdModal from './modules/OrdStoreUserSettingPwdModal'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { putAction, getAction, postAction, getFileAccessHttpUrl } from '@/api/manage'
import { frozenBatch } from '@/api/api'

export default {
  name: 'ord_store_infoList',
  mixins: [JeecgListMixin],
  components: {
    OrdStoreUserModal,
    ordStoreSettingPwdModal
  },
  data() {
    return {
      description: '门店管理页面',
      labelCol: { style: { width: '110px' } },
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '员工姓名',
          align: 'center',
          dataIndex: 'realName'
        },
        {
          title: '工号',
          align: 'center',
          dataIndex: 'workNo'
        },
        {
          title: '性别',
          align: 'center',
          dataIndex: 'sex',
          customRender: (text, record, index) => {
            if (text == '0') {
              return '女'
            } else {
              return '男'
            }
          }
        },
        {
          title: '联系手机',
          align: 'center',
          dataIndex: 'phone'
        },
        {
          title: '登录帐号',
          align: 'center',
          dataIndex: 'loginName'
        },{
          title: '状态',
          align: 'center',
          dataIndex: 'status',
          customRender: function(t, r, index) {
            if (t == '0') {
              return '无效'
            }
            return '有效'
          }
        },

        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/store/info/user/list',
        delete: '/store/info/delete'
      }
    }
  },
  computed: {},
  methods: {
    getAvatarView: function(avatar) {
      return getFileAccessHttpUrl(avatar)
    },
    handleModifyPwd: function(record) {
      this.$refs.modalModifyPwdForm.edit(record)
      this.$refs.modalModifyPwdForm.disableSubmit = false
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
